/**
 * IPS Social Suite 4
 * (c) 2013 Invision Power Services - http://www.invisionpower.com
 *
 * docs_menu.js - Menu JS controller
 *
 * Author: Invisionify.com
 */
;
(function($, _, undefined) {
    "use strict";

    ips.controller.register('fxpages.sidemenu', {

        initialize: function() {
            if( !ips.utils.responsive.enabled() || !ips.utils.responsive.currentIs('phone') ){
                this.on('click', '[data-action="expandSection"]', this.toggleSection);
                this.setup();
            }
        },

        setup: function() {
                // Do we have an active item?
                var active = this.scope.find('.ipsSideMenu_itemActive');
                if (active.length) {
                    var section = active.closest('.ipsSideMenu_closed');
                    section.toggleClass('ipsSideMenu_closed', false).toggleClass('ipsSideMenu_open', true);
                }
        },

        toggleSection: function(event) {
            var a = $(event.currentTarget);
            a.removeAttr("href");
            var li = a.closest("li");
            var expanded = li.is('.ipsSideMenu_open');

            $('.ipsSideMenu_list li.ipsSideMenu_open').removeClass('ipsSideMenu_open').addClass('ipsSideMenu_closed');
            li.toggleClass('ipsSideMenu_open', !expanded).toggleClass('ipsSideMenu_closed', expanded);

            /*
            if (expanded) {
                li.toggleClass('ipsSideMenu_closed');
            } else {
                li.toggleClass('ipsSideMenu_open');
            }


            li.toggleClass('ipsSideMenu_open', !expanded).toggleClass('ipsSideMenu_closed', expanded); */

        },

    });


}(jQuery, _));

        